<%--
  - Author		:	Jaewon Choi
  - Date			:
  - Description	:	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirScripts}/jqueryUi/css/ui-lightness/jquery-ui-1.8.21.custom.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript">
			$(function() {
			});
			function goAction(id){
				if(id == "" || ! id){
					return false;
				}
				document.frm.id.value= id;
				document.frm.submit();
			}
			
			function goPage(page){
				document.searchFrm.page.value = page;
				document.searchFrm.submit();
			}

			function goRemove(id){
				if(confirm('해당 APNS 메시지를 삭제하시겠습니까?')){
					document.removeFrm.id.value = id;
					document.removeFrm.submit();
				}
			}
		</script>
	</head>
	<body>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="menuTitle">Apple푸시메시지목록</div>
				<div class="searchWrap">
					<form name="searchFrm" action="<c:url value="/apns/list.do" />" method="post">
						<input type="hidden" name="maxnum" value="${maxnum}" />
						<input type="hidden" name="page" value="${page}" />
						<!-- 
						<ul  class="lineBlock">
							<li>
								<font>구분</font>
								<select name="gubun">
									<option value="">전체</option>
									<option value="e" <c:if test="${param.gubun eq 'e'}"> selected="selected" </c:if>>에스콰이어</option>
									<option value="h" <c:if test="${param.gubun eq 'h'}"> selected="selected" </c:if>>하퍼스바자</option>
									<option value="m" <c:if test="${param.gubun eq 'm'}"> selected="selected" </c:if>>모터트렌드</option>
									<option value="t" <c:if test="${param.gubun eq 't'}"> selected="selected" </c:if>>APNS테스트</option>
								</select>
							</li>
							<li>
								<span style="float:right;">
									<input class="btn" type="submit" value="조회" onclick="javascript:document.searchFrm.page.value=1;" />
								</span>
							</li>
						</ul>
						-->
						<input type="hidden" name="gubun" value="n">
					</form>
					<div style="text-align: right;">
						<input type="button" class="btn" value="등록" onclick="javascript:location.href='<c:url value="/apns/form.do" />';" />
					</div>
				</div>
				<form name="removeFrm" method="post" action="<c:url value="/apns/remove.do" />">
					<input type="hidden" name="maxnum" value="${maxnum}" />
					<input type="hidden" name="page" value="${page}" />
					<input type="hidden" name="fAct" value="remove">
					<input type="hidden" name="id" value="">
					<table class="listTbl">
						<colgroup>
							<col width="35px" />
							<!-- <col width="*" />
							<col width="90px" /> -->
							<col width="*" />
							<col width="90px" />
							<col width="90px" />
							<col width="80px" />
							<col width="60px" />
							<col width="35px" />
						</colgroup>
						<thead>
							<tr>
								<th>No.</th>
								<!-- <th>구분</th> -->
								<th>메시지</th>
								<th>등록일시</th>
								<th>수정일시</th>
								<th>전송예약일시</th>
								<th>전송일시</th>
								<th>전송결과</th>
								<th>삭제</th>
							</tr>
						</thead>
						<c:choose>
							<c:when test="${apnsListTotalCnt ne 0}">
								<tbody>
									<c:forEach items="${apnsList}" var="apns" varStatus="apnsStat">
										<tr class="dataTr">
											<td onclick="javascript:goAction(${apns.id});">${apnsListTotalCnt - apnsStat.index - (maxnum*(page-1))}</td>
											<!-- <td onclick="javascript:goAction(${apns.id});">
												<c:choose>
													<c:when test="${apns.gubun eq 'e'}">에스콰이어</c:when>
													<c:when test="${apns.gubun eq 'h'}">하퍼스바자</c:when>
													<c:when test="${apns.gubun eq 'm'}">모터트렌드</c:when>
													<c:when test="${apns.gubun eq 't'}">APNS테스트</c:when>
													<c:otherwise>${apns.gubun}</c:otherwise>
												</c:choose>
											</td> -->
											<td onclick="javascript:goAction(${apns.id});" style="text-align: left;">
												<c:choose>
													<c:when test="${fn:length(apns.msg) > 22}">
														<c:out value="${fn:substring(apns.msg, 0, 22)}" />...
													</c:when>
													<c:otherwise>
														<c:out value="${apns.msg}" />
													</c:otherwise>
												</c:choose>
											</td>
											<td onclick="javascript:goAction(${apns.id});" style="height: 35px;">
												<c:catch var="e">
													<fmt:parseDate var="createdTime" pattern="yyyy-MM-dd HH:mm:ss" value="${apns.createdTime}" />
													<fmt:formatDate value="${createdTime}" pattern="yyyy-MM-dd HH:mm:ss" />
												</c:catch>
												<c:if test="${not empty e}">
													<c:out value="${apns.createdTime}" />
												</c:if>
											</td>
											<td onclick="javascript:goAction(${apns.id});" style="height: 35px;">
												<c:catch var="e">
													<fmt:parseDate var="modifiedTime" pattern="yyyy-MM-dd HH:mm:ss" value="${apns.modifiedTime}" />
													<fmt:formatDate value="${modifiedTime}" pattern="yyyy-MM-dd HH:mm:ss" />
												</c:catch>
												<c:if test="${not empty e}">
													<c:out value="${apns.modifiedTime}" />
												</c:if>
											</td>
											<td class="revPushTimeWrap" onclick="javascript:goAction(${apns.id});">
												<c:catch var="e">
													<fmt:parseDate var="revPushTime" pattern="yyyy-MM-dd HH:mm:ss" value="${apns.revPushTime}" />
													<fmt:formatDate value="${revPushTime}" pattern="yyyy-MM-dd HH:mm:ss" />
												</c:catch>
												<c:if test="${not empty e}">
													${apns.revPushTime}
												</c:if>
											</td>
											<td onclick="javascript:goAction(${apns.id});">
												<c:catch var="e">
													<fmt:parseDate var="pushTime" pattern="yyyy-MM-dd HH:mm:ss" value="${apns.pushTime}" />
													<fmt:formatDate value="${pushTime}" pattern="yyyy-MM-dd HH:mm:ss" />
												</c:catch>
												<c:if test="${not empty e}">
													${apns.pushTime}
												</c:if>
											</td>
											<td onclick="javascript:goAction(${apns.id});">
												${apns.pushCnt}
											</td>
											<td class="delWrap" style="font-weight: bold; text-decoration: underline;">
												<c:if test="${apns.status eq '0'}">
													<a class="delText" href="javascript:goRemove(${apns.id});" <c:if test="${apns.status eq '1'}"> style="display:none;" </c:if>>
														삭제
													</a>
												</c:if>
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</c:when>
							<c:otherwise>
								<tfoot>
									<tr><td colspan="9" style="text-align: center;">데이터가 없습니다.</td></tr>
								</tfoot>
							</c:otherwise>
						</c:choose>
					</table>
					<c:if test="${apnsListTotalCnt ne 0}">
						<div class="pagingWrap">
							<jsp:include page="/WEB-INF/pages/includes/paging.jsp">
								<jsp:param name="totalNum" value="${apnsListTotalCnt}" />
								<jsp:param name="pageListCnt" value="${maxnum}" />
								<jsp:param name="pageGrpCnt" value="5" />
								<jsp:param name="pageIdx" value="${page}" />
							</jsp:include>
						</div>
					</c:if>
					<input type="button" class="btn" value="등록" onclick="javascript:location.href='<c:url value="/apns/form.do" />';" />
				</form>
				<form name="frm" action="<c:url value="/apns/form.do" />" method="post" style="display: none;">
					<input type="hidden" name="fAct" value="view">
					<input type="hidden" name="id" value="">
					<input type="hidden" name="maxnum" value="${maxnum}" />
					<input type="hidden" name="page" value="${page}" />
					<input type="hidden" name="searchGubun" value="${param.gubun}" />
				</form>
			</div>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
		</div>
	</body>
</html> 